using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace webapp4U.UI
{
    public partial class WebMaster_Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btDelete_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in GridViewItem.Rows)
            {
                bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;
                if (isChecked)
                {
                    int LogoID = Convert.ToInt32(((CheckBox)row.FindControl("chkSelect")).ToolTip.Trim());
                    webapp4U.BOL.Advertise.Delete(LogoID);
                }
            }

            GridViewItem.DataBind();
        }


        protected string GetAdvertise(string FileName, int Width, int Height)
        {
            Width = 130;
            Height = 130;

            if (System.IO.Path.GetExtension(FileName).ToLower() == ".swf")
                return "<script>WriteObject('" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' ," + Width + "," + Height + ");</script>";
            else
            {
                Height = -1;

                if(Width>0  && Height>0)
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 width=" + Width + " Height=" + Height + "   />";
                else if(Width > 0)
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 width=" + Width + " />";
                else if(Height > 0)
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 Height=" + Height + " />";
                else
                    return "<img src='" + Globals.ApplicationPath + "UserUpload/Logo/" + FileName + "' border=0 />";
            }
        }


        protected void btSearch_Click(object sender, EventArgs e)
        {
            GridViewItem.DataSourceID = "SearchDataSource";
            GridViewItem.DataBind();
        }
    }
}